package com.example.demo.controller;

import com.example.demo.entity.CodeRuleEntity;
import com.example.demo.entity.ProductInfo;
import com.example.demo.service.ProductInfoService;
import com.example.demo.util.GetMessage;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.stream.Collectors;

@RestController
@RequestMapping("/api/product")
@RequiredArgsConstructor
@Component
public class PrductInfoController {
    private final ProductInfoService productInfoService;

    @CrossOrigin(origins ="*" ,maxAge = 3600)
    @GetMapping("/select")
    public GetMessage selectProduct ( String appId, Integer productType) {
        ProductInfo productInfo=productInfoService.selectByAppId(appId,productType);
        if(productInfo!=null){
            return new GetMessage("成功","200",productInfo);
        }
        return new GetMessage("失败","500",null);
    }
}
